<template>
	<view>
		<view class="history-container">
			<view class="title-history">
				<view class="">历史搜索</view>
				<uni-icons type="trash-filled" size="18" @click="cleanHistory" color="#b9b9b9"></uni-icons>
			</view>
			<view class="history-item">
				<view class="item" v-for="(item, index) in historyList" :key="index" @click="toGoodsList"
					:data-text="item">{{ item }}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "search-history",
		props: {
			historyList: {
				type: Array,
				default: []
			}
		},
		data() {
			return {

			};
		},
		methods: {
			cleanHistory() {
				this.$emit('cleanHistory')
			},
			toGoodsList(e) {
				this.$emit('toGoodsList', e.currentTarget.dataset.text)
			}
		}
	}
</script>

<style>
	.history-container {
		font-size: 30rpx;
		margin-top: 62rpx;
	}

	.title-history {
		display: flex;
		justify-content: space-between;
	}

	.item {
		display: inline-block;
		padding: 12.5rpx 29rpx;
		margin-right: 21rpx;
		border-radius: 22rpx;
		background-color: #f9f9f9;
		margin-bottom: 21rpx;
	}
</style>
